#include "EdgeList.h"

EdgeList::EdgeList(void)
{
}

EdgeList::EdgeList(int *e, int n)
{
	for(int i = 0; i < n; i += 2) {
		edge new_edge = {e[i], e[i+1]};
		edge_list_.push_back(new_edge);
	}
}

EdgeList::~EdgeList(void)
{
}

int EdgeList::size() {
	return (int)edge_list_.size();
}

edge EdgeList::getEdge(int i) {
	return edge_list_.at(i);
}

bool EdgeList::ifEdge(edge e) {
	bool if_edge = 0;
	int num_edges = this->size();
	for(int i = 0; i < num_edges; i++) {
		edge next_edge = edge_list_.at(i);
		if( (e.vertex[0] == next_edge.vertex[0]) && (e.vertex[1] == next_edge.vertex[1]) ) {
			if_edge = 1;
		}
		if( (e.vertex[0] == next_edge.vertex[1]) && (e.vertex[1] == next_edge.vertex[0]) ) {
			if_edge = 1;
		}
	}
	return if_edge;
}

void EdgeList::addEdge(edge e) {
	if(!ifEdge(e)) {
		edge_list_.push_back(e);
	}
}
